
Status=['未提交','未审核','已通过','未通过']

def status_str(obj):
    if not obj.published:
        return Status[0]

    if obj.published and not obj.checked:
        return Status[1]

    if obj.published and obj.checked and not obj.passed:
        return Status[2]

    return Status[3]

def get_all_unpublish(orm):
    return orm.query.filter(published=False).all()

def get_one_unpublish(orm):
    return orm.query.filter(published=False).first()

def get_all_published_but_not_checked(orm):
    return orm.query.filter(published=True, checked=False).all()

def get_one_published_but_not_checked(orm):
    return orm.query.filter(published=True, checked=False).first()

def get_all_checked_but_not_passed(orm):
    return orm.query.filter(published=True, checked=True, passed=False).all()

def get_one_checked_but_not_passed(orm):
    return orm.query.filter(published=True, checked=True, passed=False).first()

def get_all_passed(orm):
    return orm.query.filter(checked=True, passed=True, published=True).all()

def get_one_passed(orm):
    return orm.query.filter(checked=True, passed=True, published=True).first()

def set_unpublished(obj):
    obj.published=False
    obj.checked=False
    obj.passed=False

def set_published_but_not_checked(obj):
    obj.published=True
    obj.checked=False
    obj.passed=False

def set_checked_but_not_passed(obj):
    obj.published=False
    obj.checked=True
    obj.passed=False

def set_passed(obj):
    obj.checked=True
    obj.passed=True
    obj.checked=True